package org.pcorp.battlespace.construction.ui.listener;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import org.pcorp.battlespace.construction.ui.Principal;

public class MasseListener implements DocumentListener, FocusListener {
	Principal p;
	public MasseListener(Principal p) {
		super();
		this.p = p;
	}
	
	@Override
	public void insertUpdate(DocumentEvent e) {
		
	}

	@Override
	public void removeUpdate(DocumentEvent e) {
		
	}

	@Override
	public void changedUpdate(DocumentEvent e) {
				
	}

	@Override
	public void focusGained(FocusEvent e) {
		JTextField jt = (JTextField) e.getComponent();
		jt.setSelectionStart(0);
		jt.setSelectionEnd(jt.getText().length());
	}

	@Override
	public void focusLost(FocusEvent e) {
		p.updateModel(null);
		p.updateDisplay(null);
	}

}
